const fp = require('lodash/fp')
let { Container, Maybe } = require('./support.js')

let maybe = Maybe.of([5, 6, 1])
// 1
let ex1 = (addNumber) => {
    return maybe.map(fp.map(fp.add(addNumber)))
}

// 2
let xs = Container.of(['do', 'ray', 'mi', 'fa', 'so', 'la', 'ti', 'do'])
let ex2 = () => {
    return xs.map(fp.first)
}

// 3
let safeProp = fp.curry(function (x, o) {
    return Maybe.of(o[x])
})
let user = { id: 2, name: 'Albert' }
let ex3 = () => {
    return safeProp('name')(user).map(fp.first)
}

// 4
let ex4 = (n) => {
    return Maybe.of(n).map(parseInt)
}
